@extends('layouts.app')

@section('title', '认证调试信息')

@section('content')
<div class="container mx-auto px-4 py-8">
    <div class="max-w-4xl mx-auto">
        <h1 class="text-3xl font-bold mb-8">认证调试信息</h1>
        
        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
            <!-- 认证状态 -->
            <div class="card bg-base-100 shadow-xl">
                <div class="card-body">
                    <h2 class="card-title">认证状态</h2>
                    <div class="space-y-2">
                        <p><strong>是否已登录:</strong> 
                            <span class="badge {{ Auth::check() ? 'badge-success' : 'badge-error' }}">
                                {{ Auth::check() ? '是' : '否' }}
                            </span>
                        </p>
                        @if(Auth::check())
                            <p><strong>用户ID:</strong> {{ Auth::id() }}</p>
                            <p><strong>用户名:</strong> {{ Auth::user()->name }}</p>
                            <p><strong>邮箱:</strong> {{ Auth::user()->email }}</p>
                        @endif
                    </div>
                </div>
            </div>

            <!-- 会话信息 -->
            <div class="card bg-base-100 shadow-xl">
                <div class="card-body">
                    <h2 class="card-title">会话信息</h2>
                    <div class="space-y-2">
                        <p><strong>会话ID:</strong> {{ session()->getId() }}</p>
                        <p><strong>会话驱动:</strong> {{ config('session.driver') }}</p>
                        <p><strong>CSRF Token:</strong> {{ csrf_token() }}</p>
                    </div>
                </div>
            </div>

            <!-- 请求信息 -->
            <div class="card bg-base-100 shadow-xl">
                <div class="card-body">
                    <h2 class="card-title">请求信息</h2>
                    <div class="space-y-2">
                        <p><strong>当前URL:</strong> {{ request()->url() }}</p>
                        <p><strong>用户代理:</strong> {{ request()->userAgent() }}</p>
                        <p><strong>IP地址:</strong> {{ request()->ip() }}</p>
                    </div>
                </div>
            </div>

            <!-- 环境信息 -->
            <div class="card bg-base-100 shadow-xl">
                <div class="card-body">
                    <h2 class="card-title">环境信息</h2>
                    <div class="space-y-2">
                        <p><strong>应用环境:</strong> {{ app()->environment() }}</p>
                        <p><strong>应用名称:</strong> {{ config('app.name') }}</p>
                        <p><strong>应用URL:</strong> {{ config('app.url') }}</p>
                        <p><strong>认证守卫:</strong> {{ config('auth.defaults.guard') }}</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- 会话数据 -->
        <div class="card bg-base-100 shadow-xl mt-6">
            <div class="card-body">
                <h2 class="card-title">会话数据</h2>
                <div class="overflow-x-auto">
                    <pre class="bg-base-200 p-4 rounded text-sm">{{ json_encode(session()->all(), JSON_PRETTY_PRINT) }}</pre>
                </div>
            </div>
        </div>

        <!-- 测试按钮 -->
        <div class="card bg-base-100 shadow-xl mt-6">
            <div class="card-body">
                <h2 class="card-title">测试操作</h2>
                <div class="flex gap-4">
                    <a href="{{ route('auth') }}" class="btn btn-primary">去登录页面</a>
                    <a href="{{ route('dashboard') }}" class="btn btn-secondary">去仪表板</a>
                    <a href="{{ url('/') }}" class="btn btn-accent">去首页</a>
                    @if(Auth::check())
                        <form method="POST" action="{{ route('logout') }}" class="inline">
                            @csrf
                            <button type="submit" class="btn btn-error">退出登录</button>
                        </form>
                    @endif
                </div>
            </div>
        </div>
    </div>
</div>
@endsection 